<h1>View Project "<?php echo $project->getFullCode() ?>"</h1>

  <table>
    <tbody>
      <tr>
        <th>Name:&nbsp;</th>
        <td><?php echo $project->getName() ?></td>
      </tr>
      <tr>
        <th>Code:&nbsp;</th>
        <td><?php echo $project->getCode() ?></td>
      </tr>
      <tr>
        <th>Fund:&nbsp;</th>
        <td><?php echo $project->getFund() ?></td>
      </tr>
      <tr>
        <th>Contract Type:&nbsp;</th>
        <td><?php echo $project->getContractType() ?></td>
      </tr>
      <tr>
        <th>Project Cost:&nbsp;</th>
        <td><?php echo $project->getProjectCost() ?></td>
      </tr>
      <tr>
        <th>Total Bid Amount:&nbsp;</th>
        <td><?php echo $project->getTotalBidAmount() ?></td>
      </tr>
      <tr>
        <th>Computed Overhead:&nbsp;</th>
        <td><?php echo $project->getComputedOverhead() ?></td>
      </tr>
      <tr>
        <th>Days to complete:&nbsp;</th>
        <td><?php echo $project->getDaysToComplete() ?></td>
      </tr>
      <tr>
        <th>Start Date:&nbsp;</th>
        <td><?php echo $project->getStartDate() ?></td>
      </tr>
      <tr>
        <th>End Date:&nbsp;</th>
        <td><?php echo $project->getEndDate() ?></td>
      </tr>
      <tr>
        <th>DV No:&nbsp;</th>
        <td><?php echo $project->getDVNo() ?></td>
      </tr>
      <tr>
        <th>Status:&nbsp;</th>
        <td><?php echo "<b>".$project->getStatus()."</b>" ?></td>
      </tr>
      <tr>
        <th>&nbsp;</th>
      </tr>
      <tr>
        <th>&nbsp;</th>
        <td><?php echo link_to("Edit Project","project/edit?id=".$project->getId()) ?></td>
      </tr>
    </tbody>
  </table>

<br>
Contracts:
<table border=2>
    <tr>
      <th>Category</th>
      <th>Contractor</th>
      <th>Contract Date</th>
      <th>Contract Amount</th>
      <th>Total Release</th>
      <th>Total Disbursement</th>
      <th>Balance</th>
      <th></th>
      <th></th>
      <th>Disbursement Date</th>
      <th>Release Amount</th>
      <th>Disbursement Amount</th>
    </tr>
    
    <?php foreach($project->getContracts() as $contractcontainer){$contract=$contractcontainer->getRawValue(); ?>
    <tr>
      <td><?php echo $contract->getCategory() ?></td>
      <td><?php echo $contract->getContractor() ?></td>
      <td><?php echo $contract->getDate() ?></td>
      <td align=right><?php echo MyDecimal::format($contract->getBidAmount()) ?></td>
      <td align=right><?php echo MyDecimal::format($contract->getTotalRelease()) ?></td>
      <td align=right><?php echo MyDecimal::format($contract->getTotalDisbursement()) ?></td>
      <td align=right><?php echo MyDecimal::format($contract->getBidAmount()-$contract->getTotalDisbursement()) ?></td>
      <td><?php echo link_to("Edit","contract/edit?id=".$contract["id"]); ?></td>
      <td><?php 
            $contractform=new ContractForm($contract);
            echo form_tag_for($contractform, 'contract/delete');
            echo $contractform->renderHiddenFields();
            echo "<input type=hidden name=\"contract[id]\" value=".$contract->getId()." />";
            echo "<input type=submit name=submit value=\"Delete\" />";
            echo "</form>";
          ?></td>
    </tr>

    <!--display disbursements for each contract-->
    <?php foreach($contract->getDisbursements() as $disbursement){ ?>
    <tr>
      <td colspan=9></td>
      <td><?php echo $disbursement->getDate() ?></td>
      <td align=right><?php echo MyDecimal::format($disbursement->getReleaseAmount()) ?></td>
      <td align=right><?php echo MyDecimal::format($disbursement->getDisbursementAmount()) ?></td>
      <td><?php echo link_to("Edit","disbursement/edit?id=".$disbursement["id"]); ?></td>
      <td><?php 
            $disbursementform=new DisbursementForm($disbursement);
            echo form_tag_for($disbursementform, 'disbursement/delete');
            echo $disbursementform->renderHiddenFields();
            echo "<input type=hidden name=\"disbursement[id]\" value=".$disbursement->getId()." />";
            echo "<input type=submit name=submit value=\"Delete\" />";
            echo "</form>";
          ?></td>
    </tr>
    <?php }?>
    <!--end- display disbursements for each contract-->
    <tr>
      <td colspan=9 align=right>New Disbursement:</td>
      <td>
        <?php $disbursement=new Disbursement();$disbursementform=new DisbursementForm($disbursement); ?>
        <?php echo form_tag_for($disbursementform, '@disbursement') ?>
        <?php echo $disbursementform->renderHiddenFields(); ?>
        <input type="hidden" name="disbursement[contract_id]" id="disbursement_contract_id" value="<?php echo $contract->getId()?>" />
        <?php echo $disbursementform['date'] ?>
      </td>
      <td>
        <?php echo $disbursementform['release_amount'] ?>
      </td>
      <td>
        <?php echo $disbursementform['disbursement_amount'] ?>
      </td>
      <td>
        <input type="submit" value="Save" />
        </form>
      </td>
    </tr>
    <?php }?>
  </tbody>
</table>

<br>


<!--new contract-->
New Contract:
<div class="sf_admin_form">
  <?php $contract=new Contract();$contractform=new ContractForm($contract); ?>
  <?php echo form_tag_for($contractform, '@contract') ?>
    <?php echo $contractform->renderHiddenFields() ?>
    <input type="hidden" name="contract[project_id]" id="contract_project_id" value="<?php echo $project->getId()?>" />

    <?php if ($contractform->hasGlobalErrors()): ?>
      <?php echo $contractform->renderGlobalErrors() ?>
    <?php endif; ?>
  <table>
      <tr>
        <th><?php echo 'Category' ?></th>
        <th>  </th>
        <th><?php echo 'Contractor' ?></th>
        <th>  </th>
        <th><?php echo 'Contract Date' ?></th>
        <th>  </th>
        <th><?php echo 'Contract Amount' ?></th>
      </tr>
      <tr>
        <td><?php echo $contractform['category']->renderError() ?></td>
        <td>  </td>
        <td><?php echo $contractform['contractor']->renderError() ?></td>
        <td>  </td>
        <td><?php echo $contractform['date']->renderError() ?></td>
        <td>  </td>
        <td><?php echo $contractform['bid_amount']->renderError() ?></td>
      </tr>
      <tr>
        <td><?php echo $contractform['category'] ?></td>
        <td>  </td>
        <td><?php echo $contractform['contractor'] ?></td>
        <td>  </td>
        <td><?php echo $contractform['date'] ?></td>
        <td>  </td>
        <td><?php echo $contractform['bid_amount'] ?></td>
        <td>  </td>
        <td><input type="submit" value="Save" /></td>
      </tr>
  </table>
</form>
</div>

